package Demo02;

import java.util.HashMap;
import java.util.Map;

public class Test02 {
    public static void main(String[] args) {
        HashMap hashMap = new HashMap();
        //往hashMap 容器中存放元素
        //键值对
        hashMap.put(001,"小向");
        hashMap.put(002,"小艾");
        hashMap.put(003,"小猪");
        hashMap.put(004,"小向");
        hashMap.put(005,"小向");
        System.out.println(hashMap); //{1=小向, 2=小艾, 3=小猪, 4=小向, 5=小向}

        //取值
        Object o1 = hashMap.get(001);
        String o2 = (String)hashMap.get(002);
        System.out.println(o1); //小向
        System.out.println(o2); //小艾

        System.out.println("-----------------------");

        Map<String,Integer> Map1 = new HashMap();
        Map1.put("小小", 0001);
        Map1.put("大大", 0002);
        Integer integer1 = Map1.get("小小");
        Integer integer2 = Map1.get("大大");
        System.out.println(integer1);
        System.out.println(integer2);

        System.out.println("---------------------------");


    }
}
